package reduce.fz.com.reduce.activity;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.Response;
import com.android.volley.VolleyError;

import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.bean.FindCard;
import reduce.fz.com.reduce.util.HttpUtils;
import reduce.fz.com.reduce.util.JsonUtil;

public class FindCardDetailActivity extends BaseActivity {
    private ImageView mFindCardDetailImage;
    private TextView mFindCardDetailImageAddress;
    private WebView mFindCardDetailWV;
    private FindCard card;

    @Override

    public int getContentRid() {
        return R.layout.activity_find_card_detail;
    }

    @Override
    public void initWidget() {
        mFindCardDetailImage = (ImageView) this.findViewById(R.id.find_card_detail_image);
        mFindCardDetailImageAddress = (TextView) this.findViewById(R.id.find_card_detail_image_address);
        mFindCardDetailWV = (WebView) this.findViewById(R.id.find_card_detail_webview);
    }

    @Override
    public void initListener() {

    }

    public void initData() {
        mFindCardDetailImage.setImageURI(null);
        mFindCardDetailImageAddress.setText(card.getAddress());
        mFindCardDetailWV.loadDataWithBaseURL(null, card.getText(), "text/html", "utf-8", null);
    }

    public void queryData(Long cardId) {
        HttpUtils.get("", new Response.Listener<String>() {
            @Override
            public void onResponse(String s) {
                card = JsonUtil.convert(s, FindCard.class);
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {

            }
        });

    }
}
